package com.netrust.cmsx.admin.modules.sys.web;


import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

import com.google.common.collect.Lists;
import com.netrust.cmsx.admin.modules.sys.common.AStatic;
import com.netrust.cmsx.admin.modules.sys.service.SystemService;
import com.netrust.cmsx.admin.modules.sys.utils.UserUtils;


@Controller
@RequestMapping("manager")
public class ManagerController {
	@Autowired
	private RequestMappingHandlerMapping handlerMapping;
	
	
	@ResponseBody
    @RequestMapping("/url")
    public Object getUrlMapping() {
		Map map =  this.handlerMapping.getHandlerMethods();
        Iterator<?> iterator = map.entrySet().iterator();
        List<String> urls=Lists.newArrayList();
        while(iterator.hasNext()){
            Map.Entry entry = (Map.Entry) iterator.next();
            //System.out.println(entry.getKey() +"\n" + entry.getValue());
            
            urls.add(entry.getKey().toString());
        }
        
        return urls;
    }
	
	
	/**
	 * 清除当前用户缓存
	 */
	@ResponseBody
    @RequestMapping("/cc")
	public void clearCache(){
		UserUtils.removeCache(AStatic.Cache.CACHE_AUTH_INFO);
		UserUtils.removeCache(AStatic.Cache.CACHE_ROLE_LIST);
		UserUtils.removeCache(AStatic.Cache.CACHE_MENU_LIST);
		UserUtils.removeCache(AStatic.Cache.CACHE_MENU_TREE);
		UserUtils.removeCache(AStatic.Cache.CACHE_User_Menu_List);
		UserUtils.removeCache(AStatic.Cache.CACHE_User_Menu_Tree);
	}
}
